package QL;

import java.util.List;
import java.util.ArrayList;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class ButlerGetRoomDataResponse extends BaseQLResponse
{
    /// <summary>
    /// 返回查询结果数组
    /// </summary>
    public List<ButlerRoomData> Data;

    /// <summary>
    /// 数据数量
    /// </summary>
    public long Count;

    @Override
    public void DeserializeFromJson(JSONObject jsonObj)
    {
        JSONObject t = jsonObj.getJSONObject("error_response");
        if (t != null && !t.isNullObject())
        {
            ErrCode = t.getString("code");
            ErrMsg = t.getString("msg");
        }
        else
        {
            t = jsonObj.getJSONObject("butler_get_room_data_response");
            Data = new ArrayList<ButlerRoomData>();
            JSONArray arrData = t.getJSONObject("data").getJSONArray("butler_room_data");
            for (int i = 0; i < arrData.size(); ++i)
            {
                ButlerRoomData o = new ButlerRoomData();
                o.DeserializeFromJson(arrData.getJSONObject(i));
                Data.add(o);
            }
            if (t.has("count"))
                Count = t.getLong("count");
        }
    }

}
